#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 7;
const int MOD = 1e9;
struct node {
  string s;
  int a;
  int b;
  int c;
} T[MAX];
bool cmp(node a, node b) { return a.a > b.a; }
map<string, int> m;
string s = "name|强|单|普|技\n:-----|:-----|:-----|:-----|:-----|\n";
int main() {
  freopen("data.in", "w", stdout);
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> T[i].s;
    cin >> T[i].a;
    m[T[i].s] = i;
  }
  for (int i = 1; i <= N; i++) {
    string tmp;
    cin >> tmp;
    cin >> T[m[tmp]].b;
  }
  for (int i = 1; i <= N; i++) {
    string tmp;
    cin >> tmp;
    cin >> T[m[tmp]].c;
  }
  sort(T + 1, T + 1 + N, cmp);

  cout << s;
  int a = 0, b = 0, c = 0, d = 0;
  for (int i = 1; i <= N; i++) {
    cout << T[i].s << '|';
    cout << '$';
    if (T[i].a >= 5000) {
      cout << "\\color{red}{" << T[i].a << "}";
      a++;
    } else {
      cout << T[i].a;
    }
    cout << '$';
    cout << '|';
    cout << '$';
    if (T[i].b >= 5000) {
      cout << "\\color{red}{" << T[i].b << "}";
      b++;
    } else {
      cout << T[i].b;
    }
    cout << '$';
    cout << '|';
    cout << '$';
    if (T[i].c >= 7000) {
      d++;
    }
    if (T[i].c >= 7500) {
      cout << "\\color{red}{" << T[i].c << "}";
      c++;
    } else {
      cout << T[i].c;
    }
    cout << '$';
    cout << '|';
    cout << endl;
  }
  printf("\ntotal：天%d，武%d，圣%d，至%d\n\n", a, b, c, d);
  cout << "\n```\n";
  for (int i = 1; i <= N; i++) {
    cout << T[i].s << '\n';
  }
  cout << "```\n";
}
